package com.aaa.controller;

import com.aaa.entity.Emp;
import com.aaa.service.EmpService;
import com.aaa.vo.EmpVo;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/emp")
public class EmpController {
    @Resource
    private EmpService empService;

    @RequestMapping("/selectAllEmp/{current}/{pageSize}")
    public PageInfo<Emp> selectAll(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody EmpVo empVo) {
        PageInfo<Emp> pageInfo = empService.selectAll(current, pageSize, empVo);
        return pageInfo;
    }

    @RequestMapping("/deleteById/{id}")
    public int deleteById(@PathVariable Integer id) {
        return empService.deleteByPrimaryKey(id);
    }

    @RequestMapping("/selectById/{id}")
    public Emp selectById(@PathVariable Integer id) {
        return empService.selectById(id);
    }

    @RequestMapping("/updateById")
    public int updateById(@RequestBody Emp emp) {
        return empService.updateById(emp);
    }

    @RequestMapping("/insertEmp")
    public int insertEmp(@RequestBody Emp emp) {
        return empService.insertEmp(emp);
    }
}
